package clientGUI.user.Controllers.ISD;

import clientGUI.Controllers.Controller;
import clientserver.Client;
import clientserver.Packet;
import clientserver.QueryResult;

public class ISDReportController extends Controller {

	
	private int   activerequests;
	private int   frozenrequests;
	private int  rejectedrequests;
	private int closedrequests;
	
	
	public ISDReportController( Client connectedcl)
	{
		client=connectedcl;
		frozenrequests=getnumofrozenrequests();
	int allrequests=getnumofrequests();
	activerequests=allrequests-frozenrequests;
	}
	
	public String buildReport()
	{
		String r="Active Requests: "+activerequests+
				"\n Frozen Requests: "+frozenrequests+
				"\nTotal Requests"+(activerequests+frozenrequests)+
				"\n";
				
		
		return r;
	}
	
	private int getnumofrozenrequests()
	{
		
	
		String q= "SELECT * FROM request_details WHERE current_stage>=20";
		Packet p= new Packet(q);
		QueryResult qr=(QueryResult) client.SendPacketAndWait(p);
		
		return qr.rowsize();
	}
	
	private int getnumofrequests()
	{
		String q= "SELECT * FROM request_details ";
		Packet p= new Packet(q);
		QueryResult qr=(QueryResult) client.SendPacketAndWait(p);
		return qr.rowsize();
	}
}
